package cn.lanqiao.demo.dao;


import cn.lanqiao.demo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface UserDao {
    //登录
    @Select("select * from user where username=#{username} and password=#{password}")
    public User login(User user);
    //注册
    @Insert("insert into user values(#{username},#{password})")
    public int addUser(User user);

    /**
     * 查询数据库是否已经存在用户
     */
    @Select("select * from user where username=#{username}")
    public User findUser(String username);


    //根据用户名密码修改用户密码
    @Update("update user set password = #{newPwd} where username = #{username} and password = #{password}")
    public Integer updateUserPassword(@Param("username") String nuername, @Param("password") String password, @Param("newPwd") String newPwd);
}